<?php
if( !defined( '_VALID_MOS' ) && !defined( '_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' );


/**
 * @package  SefTranslate
 * Date: 2011/04/01
 * Development Aleksey Pakholkov, Andrey Kvasnevskiy - OrdaSoft(http://ordasoft.com)
 * @copyright 2011 Andrey Kvasnevskiy-OrdaSoft(akbet@mail.ru); 
 * Homepage: http://www.ordasoft.com
 * @version: 2.0.0 Pro 

 */


require_once ( JPATH_SITE .DS.'libraries'.DS.'joomla'.DS.'database'.DS.'table.php' );


/**
* mosSefentity database table class
*/
class mosSefentity extends JTable {



//keys

	/** @var int Primary key */
	var $id=null;
	/** @var varchar(10) */
  var $lang_from=null;
	/** @var varchar(10) */
  var $lang_to=null;
  /** @var varchar(35) */
  var $hash=null;
  /** @var BLOB */
  var $entity_text=null;
  /** @var datetime */
  var $date=null;
  /** @var int */
  var $hits=null;


	/**
	* @param database - A database connector object
	*/
  function mosSefentity( &$db ) {
    parent::__construct( '#__seftranslate_entity', 'id', $db );
  }


  function loadForHash($hash,$lang_from,$lang_to){

    $this->_db->setQuery("SELECT id FROM #__seftranslate_entity WHERE hash = '$hash' and lang_from = '$lang_from' and lang_to = '$lang_to' ");
    $id = intval( $this->_db->loadResult() );

    if ($id) {
      $this->load($id );
      return $this;
    }
    else return null;
  }  


}

